#!/bin/bash

# http://blog.csdn.net/shanliangliuxing/article/details/16821175
# date +FORMAT
now=`date`
now1=`date +"%Y-%m-%d"`
now2=`date +"%Y-%m-%d %T"`
now3=`date +"%Y-%m-%d %H:%M:%S"`

echo `date`
echo $now1
echo $now2
echo $now3

# -d datestr : 显示 datestr 中所设定的时间 (非系统时间) 
# yestoday
yesterday=`date -d last-day +%Y-%m-%d`
echo 'yesterday' $yesterday

# tomorrow
tomorrow=`date -d next-day +%Y-%m-%d`
echo 'tomorrow' $tomorrow

ten_days_ago=$(date +%Y-%m-%d -d "$now -10 days")
echo 'ten_days_ago' $ten_days_ago

start=20151229
end=20160103
tmpd=`date +%Y%m%d -d $start`
while [[ $tmpd -ne $end ]]; do
    tmpd=`date +%Y%m%d -d "$tmpd +1 days"`
    echo $tmpd
done